package com.zhkj.txg.utils

import android.content.Context
import com.zhkj.lib.config.WX_APP_ID
import com.zhkj.lib.utils.ToastUtil
import com.zhkj.txg.R
import com.tencent.mm.opensdk.modelmsg.SendAuth
import com.tencent.mm.opensdk.openapi.WXAPIFactory

object ThirdLoginUtils {
    fun wxLogin(context: Context) {
        val msgApi = WXAPIFactory.createWXAPI(context, null)
        if (!msgApi.isWXAppInstalled) ToastUtil.show(context.getString(R.string.wechat_not_install))
        else {
            msgApi.registerApp(WX_APP_ID)
            msgApi.sendReq(SendAuth.Req().apply {
                scope = "snsapi_userinfo"
                state = "auth"
            })
        }
    }
}

data class ThirdLoginEvent(val success: Boolean, val code: String)